package com.thinkingstar.iads.test.urule.controller;

import java.io.IOException;

import com.bstek.urule.Utils;
import com.bstek.urule.runtime.KnowledgePackage;
import com.bstek.urule.runtime.KnowledgeSession;
import com.bstek.urule.runtime.KnowledgeSessionFactory;
import com.bstek.urule.runtime.service.KnowledgeService;

public class RuleTool {
	
	  public static KnowledgeSession getSessionFactory(String knowledgeName){
	    	KnowledgeService knowledgeService = (KnowledgeService) Utils.getApplicationContext().getBean(KnowledgeService.BEAN_ID);
	        KnowledgePackage knowledgePackage = null;
			try {
				knowledgePackage = knowledgeService.getKnowledge(knowledgeName);
			} catch (IOException e) {
				e.printStackTrace();
			}
	        return KnowledgeSessionFactory.newKnowledgeSession(knowledgePackage);
	    }
}
